﻿/*********************************************************************
 *
 *                             NOTICE
 *               COPYRIGHT (c) 2012 Panoscopix Software, Inc.
 *                UNPUBLISHED - ALL RIGHTS RESERVED
 * 
 *      This program is confidential, proprietary, and a trade
 *   secret of Panoscopix Software, Inc. The receipt or possession of
 *     this program does not convey any rights to reproduce or
 *      disclose its contents, or to manufacture, use, or sell
 *       anything that it may describe, in whole or in part, 
 *   without the specific written consent of Panoscopix Software, Inc.
 *
 * ABC for Test Cases.
 * 
 *******************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FileSystem.Utility;

namespace FileSystem.Test.TestCases
{
    abstract class TestCaseABC : TestCase
    {
        protected const String TESTCASE_DONT_CARE = null;
        protected int index;
	
	    protected TestCaseABC() {
		    index = 0;
	    }
	
	    public virtual String getLine() {
		    if (index >= getLength()) return null;
		    return getLine(index++);
	    }
	
	    public virtual bool evalResponseToPreviousLine(String response) {
		    String expected = getExpected(index-1);
            if (TESTCASE_DONT_CARE == expected) {
			    return true;
		    }
		    bool rc = StringUtil.contains(response, expected);
		    if (!rc) {
			    ConsoleOutUtil.println("****TEST FAILURE:  expected '" + expected + "'.");
		    }
		    return rc;
	    }
	
	    protected abstract int    getLength();
	    protected abstract String getLine(int i);
	    protected abstract String getExpected(int i);
    }
}
